﻿namespace Pub.Class
{
    using Microsoft.VisualBasic;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Globalization;
    using System.IO;
    using System.Linq;
    using System.Reflection;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.Runtime.Serialization;
    using System.Runtime.Serialization.Formatters.Soap;
    using System.Security;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Threading;
    using System.Web;
    using System.Web.Hosting;
    using System.Web.Script.Serialization;
    using System.Xml;
    using System.Xml.Linq;
    using System.Xml.Serialization;
    using System.Xml.XPath;

    public static class StringExtensions
    {
        private static readonly ISafeDictionary<string, Assembly> assemblyCache = new SafeDictionarySlim<string, Assembly>();
        public const string BANWORD = "(毛泽东|周恩来|刘少奇|朱德|彭德怀|林彪|刘伯承|陈毅|贺龙|聂荣臻|徐向前|罗荣桓|叶剑英|李大钊|陈独秀|孙中山|孙文|孙逸仙|邓小平|陈云|江泽民|李鹏|朱镕基|李瑞环|尉健行|李岚清|胡锦涛|罗干|温家宝|吴邦国|曾庆红|贾庆林|黄菊|吴官正|李长春|吴仪|回良玉|曾培炎|周永康|曹刚川|唐家璇|华建敏|陈至立|陈良宇|张德江|张立昌|俞正声|王乐泉|刘云山|王刚|王兆国|刘淇|贺国强|郭伯雄|胡耀邦|王乐泉|王兆国|周永康|李登辉|连战|陈水扁|宋楚瑜|吕秀莲|郁慕明|蒋介石|蒋中正|蒋经国|马英九本拉登|奥马尔|柴玲|达赖喇嘛|江青|张春桥|姚文元|王洪文|东条英机|希特勒|墨索里尼|冈村秀树|冈村宁次|高丽朴|赵紫阳|王丹|沃尔开西|李洪志|李大师|赖昌星|马加爵山本五十六|阿扁|六四|六四运动|六四大屠杀|6 4事件|中国1989 6 4事件视频|6 4事件视频|1989 6 4事件|中国1989 6 4事件|1989事件视频|北京民运89|1989年北京学生|1989年学运动|六四20年|八九民运|1989年学潮事件|四二六社论|426社论密宗|中共屠城|共产党屠城|民国|民进党|民运|民主潮|摩门教|纳粹|南华早报|南蛮|明慧网|起义|亲民党|瘸腿帮|人民报|法轮功|法轮大法|打倒共产党|台独万岁|圣战|示威|台独|台独分子|台联|台湾民国|台湾岛国|台湾独立|太子党|天安门事件|屠杀|小泉|新党|新疆独立|新疆分裂|新疆国|疆独|西藏独立|西藏分裂|西藏国|藏独|藏青会|藏妇会|学潮|学运|一党专政|一中一台|两个中国|一贯道|游行|圆满|造反|真善忍|镇压|政变|政治|政治反对派|政治犯|中共|反党|反共|政府|民主党|中国之春|转法轮|自焚|共党|共匪|苏家屯|基地组织|塔利班|东亚病夫|支那|高治联|高自联|核工业基地|核武器|铀|原子弹|氢弹|导弹|核潜艇|大参考|小参考|国内动态清样|升天|圣战 |白莲教 |东正教|大法|法轮|法轮功|瘸腿帮|真理教|真善忍|转法轮|自焚|走向圆满|黄大仙|风水|跳大神|神汉|神婆|真理教|大卫教 |藏独|高丽棒子|回回|疆独|蒙古鞑子|台独|台独分子|台联|台湾民国|西藏独立|新疆独立|南蛮|老毛子|习近平|开房|台湾岛国|藏青|藏复|本拉登|西藏国|强奸|轮奸|抢劫|先奸后杀|下注|押大|押小|抽头|坐庄|赌马|赌球|筹码|老虎机|轮盘赌|安非他命|大麻|可卡因|海洛因|冰毒|摇头丸|杜冷丁|鸦片|罂粟|迷幻药|白粉|嗑药|吸毒|屙|爱滋|淋病|梅毒|爱液|屄|逼|臭机八|臭鸡巴|吹喇叭|吹箫|催情药|屌|肛交|肛门|龟头|黄色|机八|机巴|鸡八|鸡巴|机掰|机巴|鸡叭|鸡鸡|鸡掰|鸡奸|妓女|奸|茎|精液|精子|尻|口交|滥交|乱交|轮奸|卖淫|屁眼|嫖娼|强奸|强奸犯|情色|肉棒|乳房|乳峰|乳交|乳头|乳晕|三陪|色情|射精|手淫|威而钢|威而柔|伟哥|性高潮|性交|性虐|性欲|穴|颜射|阳物|一夜情|阴部|阴唇|阴道|阴蒂|阴核|阴户|阴茎|阴门|淫|淫秽|淫乱|淫水|淫娃|淫液|淫汁|淫穴|淫洞|援交妹|做爱|梦遗|阳痿|早泄|奸淫|性欲|性交|K他命|白痴|笨蛋|屄|逼|变态|婊子|操她妈|操妳妈|操你|操你妈|操他妈|草你|肏|册那|侧那|测拿|插|蠢猪|荡妇|发骚|废物|干她妈|干妳|干妳娘|干你|干你妈|干你妈B|干你妈b|干你妈逼|干你娘|干他妈|狗娘养的|滚|鸡奸|贱货|贱人|烂人|老母|老土|妈比|妈的|马的|妳老母的|妳娘的|你妈逼|破鞋|仆街|去她妈|去妳的|去妳妈|去你的|去你妈|去死|去他妈|日你|赛她娘|赛妳娘|赛你娘|赛他娘|骚货|傻B|傻比|傻子|上妳|上你|神经病|屎|屎妳娘|屎你娘|他妈的|王八蛋|我日|乡巴佬|猪猡|屙|尿|掯|屌|骑你|湿了|操你|操他|操她|骑你|骑他|骑她|欠骑|欠人骑|来爽我|来插我|干你|干他|干她|干死|干爆|干机|FUCK|机叭|臭鸡|臭机|烂鸟|览叫|阳具|肉棒|肉壶|奶子|摸咪咪|干鸡|干入|小穴|强奸|插你|插你|爽你|爽你|干干|干X|他干|干它|干牠|干您|干汝|干林|操林|干尼|操尼|我咧干|干勒|干我|干到|干啦|干爽|欠干|狗干|我干|来干|轮干|轮流干|干一干|援交|骑你|轮奸|鸡奸|奸暴|再奸|我奸|奸你|奸你|奸他|奸她|奸一奸|淫水|淫湿|鸡歪|仆街|臭西|尻|吊|遗精|烂逼|大血比|叼你妈|靠你妈|草你|干你|日你|插你|奸你|戳你|逼你老母|挨球|我日你|草拟妈|卖逼|狗操卖逼|奸淫|日死|奶子|阴茎|奶娘|他娘|她娘|骚B|你妈了妹|逼毛|插你妈|叼你|渣波波|嫩b)";
        private static readonly ISafeDictionary<string, object> classCache = new SafeDictionarySlim<string, object>();

        public static T As<T>(this string source)
        {
            if (source.IsNull())
            {
                return default(T);
            }
            try
            {
                return (T) Convert.ChangeType(source, typeof(T));
            }
            catch
            {
                return default(T);
            }
        }

        public static string Ascii2Native(this string str)
        {
            string str2 = "";
            if (!string.IsNullOrEmpty(str))
            {
                string[] strArray = str.Replace(@"\", "").Split(new char[] { 'u' });
                for (int i = 1; i < strArray.Length; i++)
                {
                    str2 = str2 + ((char) int.Parse(strArray[i], NumberStyles.HexNumber));
                }
            }
            return str2.Trim();
        }

        public static string ChangeExtension(this string filename, string ext)
        {
            return Path.ChangeExtension(filename, ext);
        }

        public static int CharacterCount(this string value, char character)
        {
            int num = 0;
            if (value.IsNullEmpty())
            {
                return 0;
            }
            for (int i = 0; i <= (value.Length - 1); i++)
            {
                if (value.Substring(i, 1) == character.ToString())
                {
                    num++;
                }
            }
            return num;
        }

        public static void CheckOnNullEmpty(this string str, string parameterName)
        {
            if (str.IsNullEmpty())
            {
                throw new ArgumentNullException(parameterName);
            }
        }

        public static void CheckOnNullEmpty(this string str, string parameterName, string message)
        {
            if (str.IsNullEmpty())
            {
                throw new ArgumentNullException(parameterName, message);
            }
        }

        public static string ClearUBB(this string sDetail)
        {
            return Regex.Replace(sDetail, @"\[[^\]]*?\]", string.Empty, RegexOptions.IgnoreCase);
        }

        public static int CnLength(this string str)
        {
            if (str.IsNullEmpty())
            {
                return 0;
            }
            return Encoding.Default.GetBytes(str).Length;
        }

        public static bool ContainsArray(this string value, params string[] keywords)
        {
            return keywords.All<string>(s => value.Contains(s));
        }

        public static string EncodeFileName(this string fileName)
        {
            foreach (string str in Request2.Get("ALL_RAW").Split("\r\n"))
            {
                if (str.ToLower().StartsWith("user-agent"))
                {
                    if (str.ToLower().IndexOf("msie") == -1)
                    {
                        return fileName;
                    }
                    return HttpUtility.UrlEncode(fileName);
                }
            }
            return fileName;
        }

        public static bool False(this string source)
        {
            if (string.Compare(source, "false", true) != 0)
            {
                return (string.Compare(source, "0", true) == 0);
            }
            return true;
        }

        public static string Filter(this string str, string word = "")
        {
            if (str.IsNullEmpty())
            {
                return string.Empty;
            }
            string pattern = word.IsNullEmpty() ? "(毛泽东|周恩来|刘少奇|朱德|彭德怀|林彪|刘伯承|陈毅|贺龙|聂荣臻|徐向前|罗荣桓|叶剑英|李大钊|陈独秀|孙中山|孙文|孙逸仙|邓小平|陈云|江泽民|李鹏|朱镕基|李瑞环|尉健行|李岚清|胡锦涛|罗干|温家宝|吴邦国|曾庆红|贾庆林|黄菊|吴官正|李长春|吴仪|回良玉|曾培炎|周永康|曹刚川|唐家璇|华建敏|陈至立|陈良宇|张德江|张立昌|俞正声|王乐泉|刘云山|王刚|王兆国|刘淇|贺国强|郭伯雄|胡耀邦|王乐泉|王兆国|周永康|李登辉|连战|陈水扁|宋楚瑜|吕秀莲|郁慕明|蒋介石|蒋中正|蒋经国|马英九本拉登|奥马尔|柴玲|达赖喇嘛|江青|张春桥|姚文元|王洪文|东条英机|希特勒|墨索里尼|冈村秀树|冈村宁次|高丽朴|赵紫阳|王丹|沃尔开西|李洪志|李大师|赖昌星|马加爵山本五十六|阿扁|六四|六四运动|六四大屠杀|6 4事件|中国1989 6 4事件视频|6 4事件视频|1989 6 4事件|中国1989 6 4事件|1989事件视频|北京民运89|1989年北京学生|1989年学运动|六四20年|八九民运|1989年学潮事件|四二六社论|426社论密宗|中共屠城|共产党屠城|民国|民进党|民运|民主潮|摩门教|纳粹|南华早报|南蛮|明慧网|起义|亲民党|瘸腿帮|人民报|法轮功|法轮大法|打倒共产党|台独万岁|圣战|示威|台独|台独分子|台联|台湾民国|台湾岛国|台湾独立|太子党|天安门事件|屠杀|小泉|新党|新疆独立|新疆分裂|新疆国|疆独|西藏独立|西藏分裂|西藏国|藏独|藏青会|藏妇会|学潮|学运|一党专政|一中一台|两个中国|一贯道|游行|圆满|造反|真善忍|镇压|政变|政治|政治反对派|政治犯|中共|反党|反共|政府|民主党|中国之春|转法轮|自焚|共党|共匪|苏家屯|基地组织|塔利班|东亚病夫|支那|高治联|高自联|核工业基地|核武器|铀|原子弹|氢弹|导弹|核潜艇|大参考|小参考|国内动态清样|升天|圣战 |白莲教 |东正教|大法|法轮|法轮功|瘸腿帮|真理教|真善忍|转法轮|自焚|走向圆满|黄大仙|风水|跳大神|神汉|神婆|真理教|大卫教 |藏独|高丽棒子|回回|疆独|蒙古鞑子|台独|台独分子|台联|台湾民国|西藏独立|新疆独立|南蛮|老毛子|习近平|开房|台湾岛国|藏青|藏复|本拉登|西藏国|强奸|轮奸|抢劫|先奸后杀|下注|押大|押小|抽头|坐庄|赌马|赌球|筹码|老虎机|轮盘赌|安非他命|大麻|可卡因|海洛因|冰毒|摇头丸|杜冷丁|鸦片|罂粟|迷幻药|白粉|嗑药|吸毒|屙|爱滋|淋病|梅毒|爱液|屄|逼|臭机八|臭鸡巴|吹喇叭|吹箫|催情药|屌|肛交|肛门|龟头|黄色|机八|机巴|鸡八|鸡巴|机掰|机巴|鸡叭|鸡鸡|鸡掰|鸡奸|妓女|奸|茎|精液|精子|尻|口交|滥交|乱交|轮奸|卖淫|屁眼|嫖娼|强奸|强奸犯|情色|肉棒|乳房|乳峰|乳交|乳头|乳晕|三陪|色情|射精|手淫|威而钢|威而柔|伟哥|性高潮|性交|性虐|性欲|穴|颜射|阳物|一夜情|阴部|阴唇|阴道|阴蒂|阴核|阴户|阴茎|阴门|淫|淫秽|淫乱|淫水|淫娃|淫液|淫汁|淫穴|淫洞|援交妹|做爱|梦遗|阳痿|早泄|奸淫|性欲|性交|K他命|白痴|笨蛋|屄|逼|变态|婊子|操她妈|操妳妈|操你|操你妈|操他妈|草你|肏|册那|侧那|测拿|插|蠢猪|荡妇|发骚|废物|干她妈|干妳|干妳娘|干你|干你妈|干你妈B|干你妈b|干你妈逼|干你娘|干他妈|狗娘养的|滚|鸡奸|贱货|贱人|烂人|老母|老土|妈比|妈的|马的|妳老母的|妳娘的|你妈逼|破鞋|仆街|去她妈|去妳的|去妳妈|去你的|去你妈|去死|去他妈|日你|赛她娘|赛妳娘|赛你娘|赛他娘|骚货|傻B|傻比|傻子|上妳|上你|神经病|屎|屎妳娘|屎你娘|他妈的|王八蛋|我日|乡巴佬|猪猡|屙|尿|掯|屌|骑你|湿了|操你|操他|操她|骑你|骑他|骑她|欠骑|欠人骑|来爽我|来插我|干你|干他|干她|干死|干爆|干机|FUCK|机叭|臭鸡|臭机|烂鸟|览叫|阳具|肉棒|肉壶|奶子|摸咪咪|干鸡|干入|小穴|强奸|插你|插你|爽你|爽你|干干|干X|他干|干它|干牠|干您|干汝|干林|操林|干尼|操尼|我咧干|干勒|干我|干到|干啦|干爽|欠干|狗干|我干|来干|轮干|轮流干|干一干|援交|骑你|轮奸|鸡奸|奸暴|再奸|我奸|奸你|奸你|奸他|奸她|奸一奸|淫水|淫湿|鸡歪|仆街|臭西|尻|吊|遗精|烂逼|大血比|叼你妈|靠你妈|草你|干你|日你|插你|奸你|戳你|逼你老母|挨球|我日你|草拟妈|卖逼|狗操卖逼|奸淫|日死|奶子|阴茎|奶娘|他娘|她娘|骚B|你妈了妹|逼毛|插你妈|叼你|渣波波|嫩b)" : word;
            str = new Regex(pattern, RegexOptions.IgnoreCase).Replace(str, "*");
            return str;
        }

        public static MatchCollection FindBetween(this string s, string startString, string endString)
        {
            return s.FindBetween(startString, endString, true);
        }

        public static MatchCollection FindBetween(this string s, string startString, string endString, bool recursive)
        {
            if (s.IsNullEmpty())
            {
                return null;
            }
            startString = Regex.Escape(startString);
            endString = Regex.Escape(endString);
            MatchCollection matchs = new Regex("(?<=" + startString + ").*(?=" + endString + ")").Matches(s);
            if (recursive)
            {
                if (matchs.Count <= 0)
                {
                    return matchs;
                }
                if (matchs[0].ToString().IndexOf(Regex.Unescape(startString)) > -1)
                {
                    s = matchs[0].ToString() + Regex.Unescape(endString);
                    return s.FindBetween(Regex.Unescape(startString), Regex.Unescape(endString));
                }
            }
            return matchs;
        }

        public static string ForcePrefix(this string s, string prefix)
        {
            if (s.IsNullEmpty())
            {
                return string.Empty;
            }
            string str = s;
            if (!str.StartsWith(prefix))
            {
                str = prefix + str;
            }
            return str;
        }

        public static string ForceSuffix(this string s, string suffix)
        {
            if (s.IsNullEmpty())
            {
                return string.Empty;
            }
            string str = s;
            if (!str.EndsWith(suffix))
            {
                str = str + suffix;
            }
            return str;
        }

        public static string FormatToID(this string str)
        {
            return str.FormatToID(',', true);
        }

        public static string FormatToID(this string str, bool isDelZero = true)
        {
            return str.FormatToID(',', isDelZero);
        }

        public static string FormatToID(this string str, char c = ',')
        {
            return str.FormatToID(c, true);
        }

        public static string FormatToID(this string str, string c = ",")
        {
            return str.FormatToID(c, true);
        }

        public static string FormatToID(this string str, char c = ',', bool isDelZero = true)
        {
            string str2 = string.Empty;
            if (isDelZero)
            {
                foreach (string str3 in str.Split(new char[] { c }))
                {
                    long num = str3.Trim().ToBigInt();
                    if (num > 0L)
                    {
                        str2 = str2 + num.ToString() + c.ToString();
                    }
                }
            }
            else
            {
                foreach (string str4 in str.Split(new char[] { c }))
                {
                    long num2 = str4.Trim().ToBigInt();
                    str2 = str2 + ((num2 <= 0L) ? "0" : (num2.ToString() + c.ToString()));
                }
            }
            if (str2.Length > 0)
            {
                str2 = str2.Remove(str2.Length - 1, 1);
            }
            return str2;
        }

        public static string FormatToID(this string str, string c = ",", bool isDelZero = true)
        {
            string str2 = string.Empty;
            if (isDelZero)
            {
                foreach (string str3 in str.Split(c))
                {
                    long num = str3.Trim().ToBigInt();
                    if (num > 0L)
                    {
                        str2 = str2 + num.ToString() + c.ToString();
                    }
                }
            }
            else
            {
                foreach (string str4 in str.Split(c))
                {
                    long num2 = str4.Trim().ToBigInt();
                    str2 = str2 + ((num2 <= 0L) ? "0" : (num2.ToString() + c.ToString()));
                }
            }
            if (str2.Length > 0)
            {
                str2 = str2.Remove(str2.Length - 1, 1);
            }
            return str2;
        }

        public static string FormatWith(this string str, params object[] args)
        {
            return string.Format(str, args);
        }

        public static string FormatWith(this string text, object arg0)
        {
            return string.Format(text, arg0);
        }

        public static string FormatWith(this string text, IFormatProvider provider, params object[] args)
        {
            return string.Format(provider, text, args);
        }

        public static string FormatWith(this string text, object arg0, object arg1)
        {
            return string.Format(text, arg0, arg1);
        }

        public static string FormatWith(this string text, object arg0, object arg1, object arg2)
        {
            return string.Format(text, arg0, arg1, arg2);
        }

        public static T FromJson<T>(this string json)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            return serializer.Deserialize<T>(json);
        }

        public static T FromSoap<T>(this string soapXml)
        {
            using (MemoryStream stream = new MemoryStream(new UTF8Encoding().GetBytes(soapXml)))
            {
                stream.Seek(0L, SeekOrigin.Begin);
                SoapFormatter formatter = new SoapFormatter(null, new StreamingContext(StreamingContextStates.Persistence));
                return (T) formatter.Deserialize(stream);
            }
        }

        public static T FromXml<T>(this string xml)
        {
            return (T) xml.FromXml(typeof(T));
        }

        public static object FromXml(this string xml, Type type)
        {
            XmlSerializer serializer = new XmlSerializer(type);
            using (TextReader reader = new StringReader(xml))
            {
                return serializer.Deserialize(reader);
            }
        }

        public static T FromXmlFile<T>(this string fileName)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(T));
            using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {
                return (T) serializer.Deserialize(stream);
            }
        }

        public static string GB2312ToUTF8(this string str)
        {
            Encoding dstEncoding = Encoding.GetEncoding(0xfde9);
            Encoding encoding = Encoding.GetEncoding("gb2312");
            byte[] bytes = encoding.GetBytes(str);
            byte[] buffer2 = Encoding.Convert(encoding, dstEncoding, bytes);
            return dstEncoding.GetString(buffer2);
        }

        public static string GetAbsolutePath(this string strPath)
        {
            return VirtualPathUtility.ToAbsolute(strPath);
        }

        public static ISafeDictionary<string, Assembly> GetAssemblyCache()
        {
            return assemblyCache;
        }

        public static string GetBinFileFullPath(this string fileName, string ext = ".dll")
        {
            if (!ext.IsNullEmpty() && !fileName.EndsWith(ext, true, null))
            {
                fileName = fileName + ".dll";
            }
            if ((fileName.IndexOf(@"\") != -1) && (fileName.IndexOf(":") != -1))
            {
                return fileName;
            }
            if (fileName.IndexOf(@"\") != -1)
            {
                fileName = fileName.Replace(@"\", "/");
            }
            if (HttpContext.Current.IsNotNull())
            {
                return ("~/bin/" + fileName.Trim(new char[] { '/' })).GetMapPath();
            }
            return fileName.GetMapPath();
        }

        public static ISafeDictionary<string, object> GetClassCache()
        {
            return classCache;
        }

        public static string GetContentType(string extension)
        {
            switch (extension.Trim(new char[] { '.' }))
            {
                case "jpeg":
                    return "image/jpeg";

                case "jpg":
                    return "image/jpeg";

                case "js":
                    return "application/x-javascript";

                case "jsp":
                    return "text/html";

                case "gif":
                    return "image/gif";

                case "htm":
                    return "text/html";

                case "html":
                    return "text/html";

                case "asf":
                    return "video/x-ms-asf";

                case "avi":
                    return "video/avi";

                case "bmp":
                    return "application/x-bmp";

                case "asp":
                    return "text/asp";

                case "wma":
                    return "audio/x-ms-wma";

                case "wav":
                    return "audio/wav";

                case "wmv":
                    return "video/x-ms-wmv";

                case "ra":
                    return "audio/vnd.rn-realaudio";

                case "ram":
                    return "audio/x-pn-realaudio";

                case "rm":
                    return "application/vnd.rn-realmedia";

                case "rmvb":
                    return "application/vnd.rn-realmedia-vbr";

                case "xhtml":
                    return "text/html";

                case "png":
                    return "image/png";

                case "ppt":
                    return "application/x-ppt";

                case "tif":
                    return "image/tiff";

                case "tiff":
                    return "image/tiff";

                case "xls":
                    return "application/x-xls";

                case "xlw":
                    return "application/x-xlw";

                case "xml":
                    return "text/xml";

                case "xpl":
                    return "audio/scpls";

                case "swf":
                    return "application/x-shockwave-flash";

                case "torrent":
                    return "application/x-bittorrent";

                case "dll":
                    return "application/x-msdownload";

                case "asa":
                    return "text/asa";

                case "asx":
                    return "video/x-ms-asf";

                case "au":
                    return "audio/basic";

                case "css":
                    return "text/css";

                case "doc":
                    return "application/msword";

                case "exe":
                    return "application/x-msdownload";

                case "mp1":
                    return "audio/mp1";

                case "mp2":
                    return "audio/mp2";

                case "mp2v":
                    return "video/mpeg";

                case "mp3":
                    return "audio/mp3";

                case "mp4":
                    return "video/mpeg4";

                case "mpa":
                    return "video/x-mpg";

                case "mpd":
                    return "application/vnd.ms-project";

                case "mpe":
                    return "video/x-mpeg";

                case "mpeg":
                    return "video/mpg";

                case "mpg":
                    return "video/mpg";

                case "mpga":
                    return "audio/rn-mpeg";

                case "mpp":
                    return "application/vnd.ms-project";

                case "mps":
                    return "video/x-mpeg";

                case "mpt":
                    return "application/vnd.ms-project";

                case "mpv":
                    return "video/mpg";

                case "mpv2":
                    return "video/mpeg";

                case "wml":
                    return "text/vnd.wap.wml";

                case "wsdl":
                    return "text/xml";

                case "xsd":
                    return "text/xml";

                case "xsl":
                    return "text/xml";

                case "xslt":
                    return "text/xml";

                case "htc":
                    return "text/x-component";

                case "mdb":
                    return "application/msaccess";

                case "zip":
                    return "application/zip";

                case "rar":
                    return "application/x-rar-compressed";

                case "*":
                    return "application/octet-stream";

                case "001":
                    return "application/x-001";

                case "301":
                    return "application/x-301";

                case "323":
                    return "text/h323";

                case "906":
                    return "application/x-906";

                case "907":
                    return "drawing/907";

                case "a11":
                    return "application/x-a11";

                case "acp":
                    return "audio/x-mei-aac";

                case "ai":
                    return "application/postscript";

                case "aif":
                    return "audio/aiff";

                case "aifc":
                    return "audio/aiff";

                case "aiff":
                    return "audio/aiff";

                case "anv":
                    return "application/x-anv";

                case "awf":
                    return "application/vnd.adobe.workflow";

                case "biz":
                    return "text/xml";

                case "bot":
                    return "application/x-bot";

                case "c4t":
                    return "application/x-c4t";

                case "c90":
                    return "application/x-c90";

                case "cal":
                    return "application/x-cals";

                case "cat":
                    return "application/vnd.ms-pki.seccat";

                case "cdf":
                    return "application/x-netcdf";

                case "cdr":
                    return "application/x-cdr";

                case "cel":
                    return "application/x-cel";

                case "cer":
                    return "application/x-x509-ca-cert";

                case "cg4":
                    return "application/x-g4";

                case "cgm":
                    return "application/x-cgm";

                case "cit":
                    return "application/x-cit";

                case "class":
                    return "java/*";

                case "cml":
                    return "text/xml";

                case "cmp":
                    return "application/x-cmp";

                case "cmx":
                    return "application/x-cmx";

                case "cot":
                    return "application/x-cot";

                case "crl":
                    return "application/pkix-crl";

                case "crt":
                    return "application/x-x509-ca-cert";

                case "csi":
                    return "application/x-csi";

                case "cut":
                    return "application/x-cut";

                case "dbf":
                    return "application/x-dbf";

                case "dbm":
                    return "application/x-dbm";

                case "dbx":
                    return "application/x-dbx";

                case "dcd":
                    return "text/xml";

                case "dcx":
                    return "application/x-dcx";

                case "der":
                    return "application/x-x509-ca-cert";

                case "dgn":
                    return "application/x-dgn";

                case "dib":
                    return "application/x-dib";

                case "dot":
                    return "application/msword";

                case "drw":
                    return "application/x-drw";

                case "dtd":
                    return "text/xml";

                case "dwf":
                    return "application/x-dwf";

                case "dwg":
                    return "application/x-dwg";

                case "dxb":
                    return "application/x-dxb";

                case "dxf":
                    return "application/x-dxf";

                case "edn":
                    return "application/vnd.adobe.edn";

                case "emf":
                    return "application/x-emf";

                case "eml":
                    return "message/rfc822";

                case "ent":
                    return "text/xml";

                case "epi":
                    return "application/x-epi";

                case "eps":
                    return "application/x-ps";

                case "etd":
                    return "application/x-ebx";

                case "fax":
                    return "image/fax";

                case "fdf":
                    return "application/vnd.fdf";

                case "fif":
                    return "application/fractals";

                case "fo":
                    return "text/xml";

                case "frm":
                    return "application/x-frm";

                case "g4":
                    return "application/x-g4";

                case "gbr":
                    return "application/x-gbr";

                case "gcd":
                    return "application/x-gcd";

                case "gl2":
                    return "application/x-gl2";

                case "gp4":
                    return "application/x-gp4";

                case "hgl":
                    return "application/x-hgl";

                case "hmr":
                    return "application/x-hmr";

                case "hpg":
                    return "application/x-hpgl";

                case "hpl":
                    return "application/x-hpl";

                case "hqx":
                    return "application/mac-binhex40";

                case "hrf":
                    return "application/x-hrf";

                case "hta":
                    return "application/hta";

                case "htt":
                    return "text/webviewhtml";

                case "htx":
                    return "text/html";

                case "icb":
                    return "application/x-icb";

                case "ico":
                    return "application/x-ico";

                case "iff":
                    return "application/x-iff";

                case "ig4":
                    return "application/x-g4";

                case "igs":
                    return "application/x-igs";

                case "iii":
                    return "application/x-iphone";

                case "img":
                    return "application/x-img";

                case "ins":
                    return "application/x-internet-signup";

                case "isp":
                    return "application/x-internet-signup";

                case "IVF":
                    return "video/x-ivf";

                case "java":
                    return "java/*";

                case "jfif":
                    return "image/jpeg";

                case "jpe":
                    return "application/x-jpe";

                case "la1":
                    return "audio/x-liquid-file";

                case "lar":
                    return "application/x-laplayer-reg";

                case "latex":
                    return "application/x-latex";

                case "lavs":
                    return "audio/x-liquid-secure";

                case "lbm":
                    return "application/x-lbm";

                case "lmsff":
                    return "audio/x-la-lms";

                case "ls":
                    return "application/x-javascript";

                case "ltr":
                    return "application/x-ltr";

                case "m1v":
                    return "video/x-mpeg";

                case "m2v":
                    return "video/x-mpeg";

                case "m3u":
                    return "audio/mpegurl";

                case "m4e":
                    return "video/mpeg4";

                case "mac":
                    return "application/x-mac";

                case "man":
                    return "application/x-troff-man";

                case "math":
                    return "text/xml";

                case "mfp":
                    return "application/x-shockwave-flash";

                case "mht":
                    return "message/rfc822";

                case "mhtml":
                    return "message/rfc822";

                case "mi":
                    return "application/x-mi";

                case "mid":
                    return "audio/mid";

                case "midi":
                    return "audio/mid";

                case "mil":
                    return "application/x-mil";

                case "mml":
                    return "text/xml";

                case "mnd":
                    return "audio/x-musicnet-download";

                case "mns":
                    return "audio/x-musicnet-stream";

                case "mocha":
                    return "application/x-javascript";

                case "movie":
                    return "video/x-sgi-movie";

                case "mpw":
                    return "application/vnd.ms-project";

                case "mpx":
                    return "application/vnd.ms-project";

                case "mtx":
                    return "text/xml";

                case "mxp":
                    return "application/x-mmxp";

                case "net":
                    return "image/pnetvue";

                case "nrf":
                    return "application/x-nrf";

                case "nws":
                    return "message/rfc822";

                case "odc":
                    return "text/x-ms-odc";

                case "out":
                    return "application/x-out";

                case "p10":
                    return "application/pkcs10";

                case "p12":
                    return "application/x-pkcs12";

                case "p7b":
                    return "application/x-pkcs7-certificates";

                case "p7c":
                    return "application/pkcs7-mime";

                case "p7m":
                    return "application/pkcs7-mime";

                case "p7r":
                    return "application/x-pkcs7-certreqresp";

                case "p7s":
                    return "application/pkcs7-signature";

                case "pc5":
                    return "application/x-pc5";

                case "pci":
                    return "application/x-pci";

                case "pcl":
                    return "application/x-pcl";

                case "pcx":
                    return "application/x-pcx";

                case "pdf":
                    return "application/pdf";

                case "pdx":
                    return "application/vnd.adobe.pdx";

                case "pfx":
                    return "application/x-pkcs12";

                case "pgl":
                    return "application/x-pgl";

                case "pic":
                    return "application/x-pic";

                case "pko":
                    return "application/vnd.ms-pki.pko";

                case "pl":
                    return "application/x-perl";

                case "plg":
                    return "text/html";

                case "pls":
                    return "audio/scpls";

                case "plt":
                    return "application/x-plt";

                case "pot":
                    return "application/vnd.ms-powerpoint";

                case "ppa":
                    return "application/vnd.ms-powerpoint";

                case "ppm":
                    return "application/x-ppm";

                case "pps":
                    return "application/vnd.ms-powerpoint";

                case "pr":
                    return "application/x-pr";

                case "prf":
                    return "application/pics-rules";

                case "prn":
                    return "application/x-prn";

                case "prt":
                    return "application/x-prt";

                case "ps":
                    return "application/x-ps";

                case "ptn":
                    return "application/x-ptn";

                case "pwz":
                    return "application/vnd.ms-powerpoint";

                case "r3t":
                    return "text/vnd.rn-realtext3d";

                case "ras":
                    return "application/x-ras";

                case "rat":
                    return "application/rat-file";

                case "rdf":
                    return "text/xml";

                case "rec":
                    return "application/vnd.rn-recording";

                case "red":
                    return "application/x-red";

                case "rgb":
                    return "application/x-rgb";

                case "rjs":
                    return "application/vnd.rn-realsystem-rjs";

                case "rjt":
                    return "application/vnd.rn-realsystem-rjt";

                case "rlc":
                    return "application/x-rlc";

                case "rle":
                    return "application/x-rle";

                case "rmf":
                    return "application/vnd.adobe.rmf";

                case "rmi":
                    return "audio/mid";

                case "rmj":
                    return "application/vnd.rn-realsystem-rmj";

                case "rmm":
                    return "audio/x-pn-realaudio";

                case "rmp":
                    return "application/vnd.rn-rn_music_package";

                case "rms":
                    return "application/vnd.rn-realmedia-secure";

                case "rmx":
                    return "application/vnd.rn-realsystem-rmx";

                case "rnx":
                    return "application/vnd.rn-realplayer";

                case "rp":
                    return "image/vnd.rn-realpix";

                case "rpm":
                    return "audio/x-pn-realaudio-plugin";

                case "rsml":
                    return "application/vnd.rn-rsml";

                case "rt":
                    return "text/vnd.rn-realtext";

                case "rtf":
                    return "application/msword";

                case "rv":
                    return "video/vnd.rn-realvideo";

                case "sam":
                    return "application/x-sam";

                case "sat":
                    return "application/x-sat";

                case "sdp":
                    return "application/sdp";

                case "sdw":
                    return "application/x-sdw";

                case "sit":
                    return "application/x-stuffit";

                case "slb":
                    return "application/x-slb";

                case "sld":
                    return "application/x-sld";

                case "slk":
                    return "drawing/x-slk";

                case "smi":
                    return "application/smil";

                case "smil":
                    return "application/smil";

                case "smk":
                    return "application/x-smk";

                case "snd":
                    return "audio/basic";

                case "sol":
                    return "text/plain";

                case "sor":
                    return "text/plain";

                case "spc":
                    return "application/x-pkcs7-certificates";

                case "spl":
                    return "application/futuresplash";

                case "spp":
                    return "text/xml";

                case "ssm":
                    return "application/streamingmedia";

                case "sst":
                    return "application/vnd.ms-pki.certstore";

                case "stl":
                    return "application/vnd.ms-pki.stl";

                case "stm":
                    return "text/html";

                case "sty":
                    return "application/x-sty";

                case "svg":
                    return "text/xml";

                case "tdf":
                    return "application/x-tdf";

                case "tg4":
                    return "application/x-tg4";

                case "tga":
                    return "application/x-tga";

                case "tld":
                    return "text/xml";

                case "top":
                    return "drawing/x-top";

                case "tsd":
                    return "text/xml";

                case "txt":
                    return "text/plain";

                case "uin":
                    return "application/x-icq";

                case "uls":
                    return "text/iuls";

                case "vcf":
                    return "text/x-vcard";

                case "vda":
                    return "application/x-vda";

                case "vdx":
                    return "application/vnd.visio";

                case "vml":
                    return "text/xml";

                case "vpg":
                    return "application/x-vpeg005";

                case "vsd":
                    return "application/vnd.visio";

                case "vss":
                    return "application/vnd.visio";

                case "vst":
                    return "application/vnd.visio";

                case "vsw":
                    return "application/vnd.visio";

                case "vsx":
                    return "application/vnd.visio";

                case "vtx":
                    return "application/vnd.visio";

                case "vxml":
                    return "text/xml";

                case "wax":
                    return "audio/x-ms-wax";

                case "wb1":
                    return "application/x-wb1";

                case "wb2":
                    return "application/x-wb2";

                case "wb3":
                    return "application/x-wb3";

                case "wbmp":
                    return "image/vnd.wap.wbmp";

                case "wiz":
                    return "application/msword";

                case "wk3":
                    return "application/x-wk3";

                case "wk4":
                    return "application/x-wk4";

                case "wkq":
                    return "application/x-wkq";

                case "wks":
                    return "application/x-wks";

                case "wm":
                    return "video/x-ms-wm";

                case "wmd":
                    return "application/x-ms-wmd";

                case "wmf":
                    return "application/x-wmf";

                case "wmx":
                    return "video/x-ms-wmx";

                case "wmz":
                    return "application/x-ms-wmz";

                case "wp6":
                    return "application/x-wp6";

                case "wpd":
                    return "application/x-wpd";

                case "wpg":
                    return "application/x-wpg";

                case "wpl":
                    return "application/vnd.ms-wpl";

                case "wq1":
                    return "application/x-wq1";

                case "wr1":
                    return "application/x-wr1";

                case "wri":
                    return "application/x-wri";

                case "wrk":
                    return "application/x-wrk";

                case "ws":
                    return "application/x-ws";

                case "ws2":
                    return "application/x-ws";

                case "wsc":
                    return "text/scriptlet";

                case "wvx":
                    return "video/x-ms-wvx";

                case "xdp":
                    return "application/vnd.adobe.xdp";

                case "xdr":
                    return "text/xml";

                case "xfd":
                    return "application/vnd.adobe.xfd";

                case "xfdf":
                    return "application/vnd.adobe.xfdf";

                case "xq":
                    return "text/xml";

                case "xql":
                    return "text/xml";

                case "xquery":
                    return "text/xml";

                case "xwd":
                    return "application/x-xwd";

                case "x_b":
                    return "application/x-x_b";

                case "x_t":
                    return "application/x-x_t";
            }
            return "application/octet-stream";
        }

        public static string GetEmailHostName(this string strEmail)
        {
            if (!strEmail.IsNullEmpty() && (strEmail.IndexOf("@") >= 0))
            {
                return strEmail.Substring(strEmail.LastIndexOf("@")).ToLower();
            }
            return string.Empty;
        }

        public static string GetExtension(this string filename)
        {
            return Path.GetExtension(filename).Trim(".");
        }

        public static string GetFileName(this string filename)
        {
            return Path.GetFileName(filename);
        }

        public static string GetFileNameWithoutExtension(this string filename)
        {
            return Path.GetFileNameWithoutExtension(filename);
        }

        public static string GetGlobalMapPath(this string strPath)
        {
            return HostingEnvironment.MapPath(strPath);
        }

        public static IList<string> GetHref(this string HtmlCode)
        {
            IList<string> list = new List<string>();
            if (!HtmlCode.IsNullEmpty())
            {
                string pattern = "(h|H)(r|R)(e|E)(f|F) *= *('|\")?((\\w|\\\\|\\/|\\.|:|-|_)+)('|\"| *|>)?";
                foreach (Match match in Regex.Matches(HtmlCode, pattern))
                {
                    list.Add(match.Value.ToLower().Replace("href=", "").Trim().TrimEnd(new char[] { '\'' }).TrimEnd(new char[] { '"' }).TrimStart(new char[] { '\'' }).TrimStart(new char[] { '"' }));
                }
            }
            return list;
        }

        public static Encoding GetHtmlEncoding(this string contentType, Encoding defaultEncoding)
        {
            Encoding encoding = defaultEncoding;
            string key = new Regex(@"charset\s*=\s*(?<encode>(\w*(-|_|\.|)*\w*)+)\s*").Match(contentType).Groups["encode"].Value.ToLower().Trim();
            Hashtable hashtable = new Hashtable();
            hashtable.Add("utf8", "utf-8");
            hashtable.Add("gb_2312", "gb2312");
            hashtable.Add("'utf_8'", "utf-8");
            hashtable.Add("zh_cn", "gbk");
            hashtable.Add("utf_8", "utf-8");
            if (hashtable.Contains(key))
            {
                key = hashtable[key].ToString();
            }
            if (key.Length > 0)
            {
                return Encoding.GetEncoding(key);
            }
            return defaultEncoding;
        }

        public static List<string> GetLines(this string text)
        {
            return text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None).ToList<string>();
        }

        public static string GetMapPath(this string strPath)
        {
            if (HttpContext.Current.IsNotNull())
            {
                return HttpContext.Current.Server.MapPath(strPath);
            }
            strPath = strPath.Replace("/", @"\");
            if (strPath.StartsWith(@".\"))
            {
                strPath = strPath.Substring(2);
            }
            strPath = strPath.TrimStart(new char[] { '~' }).TrimStart(new char[] { '\\' });
            return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath);
        }

        public static MatchCollection GetMatches(this string value, string regexPattern)
        {
            if (value.IsNullEmpty())
            {
                return null;
            }
            return value.GetMatches(regexPattern, RegexOptions.None);
        }

        public static MatchCollection GetMatches(this string value, string regexPattern, RegexOptions options)
        {
            if (value.IsNullEmpty())
            {
                return null;
            }
            return Regex.Matches(value, regexPattern, options);
        }

        public static IEnumerable<string> GetMatchingValues(this string value, string regexPattern)
        {
            return value.GetMatchingValues(regexPattern, RegexOptions.None);
        }

        public static IEnumerable<string> GetMatchingValues(this string value, string regexPattern, RegexOptions options)
        {
            IEnumerator enumerator = value.GetMatches(regexPattern, options).GetEnumerator();
            while (enumerator.MoveNext())
            {
                Match current = (Match) enumerator.Current;
                if (current.Success)
                {
                    yield return current.Value;
                }
            }
        }

        public static IList<string> GetMatchingValues(this string value, string regexPattern, string rep1, string rep2)
        {
            IList<string> list = new List<string>();
            if (!value.IsNullEmpty())
            {
                string item = "";
                foreach (Match match in Regex.Matches(value, regexPattern))
                {
                    item = match.Value.Trim().Replace(rep1, "").Replace(rep2, "");
                    list.Add(item);
                }
            }
            return list;
        }

        public static string GetMimeType(this string str)
        {
            return Encoding.UTF8.GetBytes(str).GetMimeType();
        }

        public static string GetParentPath(this string path)
        {
            return path.GetParentPath('/');
        }

        public static string GetParentPath(this string path, char c = '/')
        {
            if (string.IsNullOrEmpty(path))
            {
                return null;
            }
            int length = path.TrimEnd(new char[] { c }).LastIndexOf(c);
            if (length == -1)
            {
                return null;
            }
            return (path.Substring(0, length) + c);
        }

        public static string GetSimpleFileName(this string fullname, string repstring, int leftnum, int rightnum, int charnum)
        {
            string str2 = "";
            string str3 = "";
            string str4 = "";
            string extension = fullname.GetExtension();
            if (extension.IsNullEmpty())
            {
                return fullname;
            }
            int num = 0;
            int length = 0;
            length = fullname.LastIndexOf('.');
            str4 = fullname.Substring(0, length);
            num = str4.Length;
            if (length <= charnum)
            {
                return fullname;
            }
            str2 = str4.Substring(0, leftnum);
            str3 = str4.Substring(num - rightnum, rightnum);
            if ((repstring == "") || repstring.IsNull())
            {
                return (str2 + str3 + extension);
            }
            return (str2 + repstring + str3 + extension);
        }

        public static IList<string> GetSrc(this string HtmlCode)
        {
            IList<string> list = new List<string>();
            if (!HtmlCode.IsNullEmpty())
            {
                string pattern = "(s|S)(r|R)(c|C) *= *('|\")?((\\w|\\\\|\\/|\\.|:|-|_)+)('|\"| *|>)?";
                foreach (Match match in Regex.Matches(HtmlCode, pattern))
                {
                    list.Add(match.Value.ToLower().Replace("src=", "").Trim().TrimEnd(new char[] { '\'' }).TrimEnd(new char[] { '"' }).TrimStart(new char[] { '\'' }).TrimStart(new char[] { '"' }));
                }
            }
            return list;
        }

        public static string GetUrlFileName(this string url)
        {
            if (url.IsNullEmpty())
            {
                return string.Empty;
            }
            string[] strArray = url.Split(new char[] { '/' });
            return strArray[strArray.Length - 1].Split(new char[] { '?' })[0];
        }

        public static string HtmlDecode(this string str)
        {
            if (str.IsNullEmpty())
            {
                return string.Empty;
            }
            return HttpUtility.HtmlDecode(str);
        }

        public static string HtmlEncode(this string str)
        {
            if (str.IsNullEmpty())
            {
                return string.Empty;
            }
            return HttpUtility.HtmlEncode(str);
        }

        public static string IfEqual(this string obj, string value, string defaultValue)
        {
            if (!obj.IsNullEmpty() && !(obj == value))
            {
                return obj;
            }
            return defaultValue;
        }

        public static string IfLengthEqual(this string obj, int length, string defaultValue)
        {
            if (!obj.IsNullEmpty() && (obj.Length != length))
            {
                return obj;
            }
            return defaultValue;
        }

        public static string IfLengthLessThan(this string obj, int length, string defaultValue)
        {
            if (!obj.IsNullEmpty() && (obj.Length >= length))
            {
                return obj;
            }
            return defaultValue;
        }

        public static string IfLengthLessThanOrEqual(this string obj, int length, string defaultValue)
        {
            if (!obj.IsNullEmpty() && (obj.Length > length))
            {
                return obj;
            }
            return defaultValue;
        }

        public static string IfLengthMoreThan(this string obj, int length, string defaultValue)
        {
            if (!obj.IsNullEmpty() && (obj.Length <= length))
            {
                return obj;
            }
            return defaultValue;
        }

        public static string IfLengthMoreThanOrEqual(this string obj, int length, string defaultValue)
        {
            if (!obj.IsNullEmpty() && (obj.Length < length))
            {
                return obj;
            }
            return defaultValue;
        }

        public static string IfLengthNotEqual(this string obj, int length, string defaultValue)
        {
            if (!obj.IsNullEmpty() && (obj.Length == length))
            {
                return obj;
            }
            return defaultValue;
        }

        public static string IfNotEqual(this string obj, string value, string defaultValue)
        {
            if (!(obj != value))
            {
                return obj;
            }
            return defaultValue;
        }

        public static string IfNullOrEmpty(this string obj, string defaultValue)
        {
            if (!obj.IsNullEmpty())
            {
                return obj;
            }
            return defaultValue;
        }

        public static bool IsAlpha(this string input)
        {
            return input.IsMatch("[^a-zA-Z0-9]");
        }

        public static bool IsAscii(this string data)
        {
            if (!data.IsNull() && (data.Length != 0))
            {
                foreach (char ch in data)
                {
                    if (ch > '\x007f')
                    {
                        return false;
                    }
                }
            }
            return true;
        }

        public static bool IsBase64(this string str)
        {
            return Regex.IsMatch(str, @"[A-Za-z0-9\+\/\=]");
        }

        public static bool IsBinary(this string str)
        {
            for (int i = 0; i < str.Length; i++)
            {
                if (str[i] > '\x00ff')
                {
                    return false;
                }
            }
            return true;
        }

        public static bool IsCNStr(this string s)
        {
            string[] strArray = new string[] { @"[\u3040-\u318f]+", @"[\u3300-\u337f]+", @"[\u3400-\u3d2d]+", @"[\u4e00-\u9fff]+", @"[\u4e00-\u9fa5]+", @"[\uf900-\ufaff]+" };
            foreach (string str in strArray)
            {
                if (Regex.IsMatch(s, str))
                {
                    return true;
                }
            }
            return false;
        }

        public static bool IsColor(this string color)
        {
            if (color.IsNullEmpty())
            {
                return false;
            }
            color = color.Trim().Trim(new char[] { '#' });
            if ((color.Length != 3) && (color.Length != 6))
            {
                return false;
            }
            return !Regex.IsMatch(color, "[^0-9a-f]", RegexOptions.IgnoreCase);
        }

        public static bool IsCreditCard(this string s)
        {
            return new Regex(@"^(\d{14}|\d{17})(\d|[xX])$").IsMatch(s);
        }

        public static bool IsDate(this string DateStr)
        {
            try
            {
                DateTime.Parse(DateStr);
                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool IsDateTime(this string input)
        {
            string op = @"^(?=\d)(?:(?!(?:1582(?:\.|-|\/)10(?:\.|-|\/)(?:0?[5-9]|1[0-4]))|(?:1752(?:\.|-|\/)0?9(?:\.|-|\/)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\.|-|\/)(?:29|30))))(\d{4})([-\/.])(0?\d|1[012])\2((?!00)[012]?\d|3[01])(?:$|(?=\x20\d)\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2}(?:\x20[aApP][mM]))|(?:[01]?\d|2[0-3])(?::[0-5]\d){1,2})?$";
            return input.IsMatch(op);
        }

        public static bool IsDateTime2(this string DateTimeStr)
        {
            try
            {
                DateTime.Parse(DateTimeStr);
                return true;
            }
            catch
            {
                return false;
            }
        }

        public static bool IsDouble(this string input)
        {
            string op = "^[0-9]*[1-9][0-9]*$";
            return input.IsMatch(op);
        }

        public static bool IsEmail(this string input)
        {
            string op = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
            return input.IsMatch(op);
        }

        public static bool IsGroupName(this string str)
        {
            return new Regex("^[^\\/\"{}<>:?*|]+$", RegexOptions.Compiled).IsMatch(str);
        }

        public static bool IsGuid(this string s)
        {
            if (s.IsNullEmpty())
            {
                return false;
            }
            Regex regex = new Regex(@"^[A-Fa-f0-9]{32}$|^({|\()?[A-Fa-f0-9]{8}-([A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12}(}|\))?$|^({)?[0xA-Fa-f0-9]{3,10}(, {0,1}[0xA-Fa-f0-9]{3,6}){2},{0,1}({)([0xA-Fa-f0-9]{3,4}, {0,1}){7}[0xA-Fa-f0-9]{3,4}(}})$");
            return regex.Match(s).Success;
        }

        public static bool IsImgFile(this string filename)
        {
            if (FileDirectory.FileExists(filename))
            {
                switch (BitConverter.ToUInt16(File.ReadAllBytes(filename), 0))
                {
                    case 0x4947:
                        return true;

                    case 0x4949:
                        return true;

                    case 0x4d42:
                        return true;

                    case 0x50a:
                        return true;

                    case 0x4238:
                        return true;

                    case 0x5089:
                        return true;

                    case 0xa659:
                        return true;

                    case 0xd8ff:
                        return true;

                    case 0xda01:
                        return true;
                }
            }
            return false;
        }

        public static bool IsImgFileName(this string filename)
        {
            filename = filename.Trim();
            if (filename.EndsWith(".") || (filename.IndexOf(".") == -1))
            {
                return false;
            }
            string str = filename.Substring(filename.LastIndexOf(".") + 1).ToLower();
            if (((str != "jpg") && (str != "jpeg")) && ((str != "png") && (str != "bmp")))
            {
                return (str == "gif");
            }
            return true;
        }

        public static bool IsInArray(this string stringarray, string str)
        {
            return stringarray.Split(",").IsInArray(str, false);
        }

        public static bool IsInArray(this string stringarray, string str, string strsplit)
        {
            return stringarray.Split(strsplit).IsInArray(str, false);
        }

        public static bool IsInArray(this string stringarray, string str, string strsplit, bool caseInsensetive)
        {
            return stringarray.Split(strsplit).IsInArray(str, caseInsensetive);
        }

        public static bool IsInt(this string input)
        {
            string op = "^[0-9]*$";
            return input.IsMatch(op);
        }

        public static bool IsIP(this string input)
        {
            return input.IsMatch(@"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$");
        }

        public static bool IsIPSect(this string ip)
        {
            return ip.IsMatch(@"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){2}((2[0-4]\d|25[0-5]|[01]?\d\d?|\*)\.)(2[0-4]\d|25[0-5]|[01]?\d\d?|\*)$");
        }

        public static bool IsMatch(this string str, string op)
        {
            if (str.IsNullEmpty())
            {
                return false;
            }
            Regex regex = new Regex(op, RegexOptions.IgnoreCase);
            return regex.IsMatch(str);
        }

        public static bool IsMobile(this string input)
        {
            return input.IsMatch(@"^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$");
        }

        public static bool IsNickName(this string str)
        {
            return new Regex(@"^[a-zA-Z\u4e00-\u9fa5\d_]+$", RegexOptions.Compiled).IsMatch(str);
        }

        public static bool IsNull(this Guid? guid)
        {
            return (guid.IsNull() || (guid == Guid.Empty));
        }

        public static bool IsNullEmpty(this string str)
        {
            return ((str == null) || string.IsNullOrEmpty(str));
        }

        public static string IsNullEmpty(this string str, string defaultValue)
        {
            if (!str.IsNullEmpty())
            {
                return str;
            }
            return defaultValue;
        }

        public static bool IsNumber(this string strNumber)
        {
            string op = @"^([0-9])[0-9]*(\.\w*)?$";
            return strNumber.IsMatch(op);
        }

        public static bool IsNumberArray(this string[] strNumber)
        {
            if (strNumber.IsNull())
            {
                return false;
            }
            if (strNumber.Length < 1)
            {
                return false;
            }
            foreach (string str in strNumber)
            {
                if (!str.IsNumber())
                {
                    return false;
                }
            }
            return true;
        }

        public static bool IsSafeSqlStr(this string str)
        {
            return !Regex.IsMatch(str, @"[-|;|,|\/|\(|\)|\[|\]|\}|\{|%|@|\*|!|\']");
        }

        public static bool IsStrongPassword(this string password)
        {
            return Regex.IsMatch(password, @"(?=^.{8,255}$)((?=.*\d)(?=.*[A-Z])(?=.*[a-z])|(?=.*\d)(?=.*[^A-Za-z0-9])(?=.*[a-z])|(?=.*[^A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z])|(?=.*\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9]))^.*");
        }

        public static bool IsTelepone(this string input)
        {
            return input.IsMatch(@"^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$");
        }

        public static bool IsTime(this string TimeStr)
        {
            return TimeStr.IsMatch(@"^([0-1]\\d|2[0-3]):[0-5]\\d:[0-5]\\d$");
        }

        public static bool IsUnicode(this string Input)
        {
            if (!string.IsNullOrEmpty(Input))
            {
                UnicodeEncoding encoding = new UnicodeEncoding();
                string str = encoding.GetString(encoding.GetBytes(Input));
                ASCIIEncoding encoding2 = new ASCIIEncoding();
                string str2 = encoding2.GetString(encoding2.GetBytes(Input));
                if (str == str2)
                {
                    return false;
                }
            }
            return true;
        }

        public static bool IsUrl(this string input)
        {
            string op = @"^(http|https)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{1,10}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$";
            return input.IsMatch(op);
        }

        public static bool IsUserName(this string str)
        {
            return new Regex(@"^[a-zA-Z\d_]+$", RegexOptions.Compiled).IsMatch(str);
        }

        public static bool IsYear(this string input)
        {
            int num = input.ToInt();
            return ((num >= 0x76c) && (num <= 0x270f));
        }

        public static bool IsZip(this string input)
        {
            return input.IsMatch(@"\d{6}");
        }

        public static string JsonFilter(this string sourceStr)
        {
            sourceStr = sourceStr.Replace(@"\", @"\\");
            sourceStr = sourceStr.Replace("\b", "\\\b");
            sourceStr = sourceStr.Replace("\t", "\\\t");
            sourceStr = sourceStr.Replace("\n", "\\\n");
            sourceStr = sourceStr.Replace("\n", "\\\n");
            sourceStr = sourceStr.Replace("\f", "\\\f");
            sourceStr = sourceStr.Replace("\r", "\\\r");
            return sourceStr.Replace("\"", "\\\"");
        }

        public static string Left(this string str, int length)
        {
            if ((length <= 0) || (str.Length == 0))
            {
                return string.Empty;
            }
            if (str.Length <= length)
            {
                return str;
            }
            return str.Substring(0, length);
        }

        public static Assembly LoadAssembly(this string assembly)
        {
            if (((assembly.IndexOf(@"\") != -1) || (assembly.IndexOf("/") != -1)) || assembly.EndsWith(".dll", true, null))
            {
                return assembly.LoadDLLAssembly();
            }
            if (assemblyCache.ContainsKey(assembly))
            {
                return assemblyCache[assembly];
            }
            Assembly assembly2 = Assembly.Load(assembly);
            assemblyCache.Add(assembly, assembly2);
            return assembly2;
        }

        public static object LoadClass(this string classNameAndAssembly)
        {
            if (((classNameAndAssembly.IndexOf(@"\") != -1) || (classNameAndAssembly.IndexOf("/") != -1)) || classNameAndAssembly.EndsWith(".dll", true, null))
            {
                string[] strArray = classNameAndAssembly.Split(new char[] { ',' });
                return strArray[1].LoadDLLClass(strArray[0]);
            }
            if (classCache.ContainsKey(classNameAndAssembly))
            {
                return classCache[classNameAndAssembly];
            }
            object obj2 = Activator.CreateInstance(Type.GetType(classNameAndAssembly, false, true));
            classCache.Add(classNameAndAssembly, obj2);
            return obj2;
        }

        public static object LoadClass(this string assembly, string className = "")
        {
            if (((assembly.IndexOf(@"\") != -1) || (assembly.IndexOf("/") != -1)) || assembly.EndsWith(".dll", true, null))
            {
                return assembly.LoadDLLClass(className);
            }
            if (classCache.ContainsKey(assembly + className))
            {
                return classCache[assembly + className];
            }
            object obj2 = Activator.CreateInstance(assembly.LoadAssembly().GetType(className, false, true));
            classCache.Add(assembly + className, obj2);
            return obj2;
        }

        public static Assembly LoadDLLAssembly(this string dllFullPath)
        {
            if (assemblyCache.ContainsKey(dllFullPath))
            {
                return assemblyCache[dllFullPath];
            }
            Assembly assembly = Assembly.LoadFrom(dllFullPath.GetBinFileFullPath(".dll"));
            assemblyCache.Add(dllFullPath, assembly);
            return assembly;
        }

        public static object LoadDLLClass(this string dllFileName, string className = "")
        {
            dllFileName = dllFileName.GetBinFileFullPath(".dll");
            className = (className.Length == 0) ? dllFileName.GetFileNameWithoutExtension() : className;
            if (classCache.ContainsKey(dllFileName + className))
            {
                return classCache[dllFileName + className];
            }
            object obj2 = Activator.CreateInstance(dllFileName.LoadDLLAssembly().GetType(className, false, true));
            classCache.Add(dllFileName + className, obj2);
            return obj2;
        }

        public static object LoadDynamicClass(this string assembly, string className = "")
        {
            if (((assembly.IndexOf(@"\") != -1) || (assembly.IndexOf("/") != -1)) || assembly.EndsWith(".dll", true, null))
            {
                return assembly.LoadDynamicDLLClass(className);
            }
            if (classCache.ContainsKey(assembly + className))
            {
                return classCache[assembly + className];
            }
            object obj2 = Activator.CreateInstance(assembly.LoadAssembly().GetType(className, false, true));
            classCache.Add(assembly + className, obj2);
            return obj2;
        }

        public static Assembly LoadDynamicDLLAssembly(this string dllFullPath)
        {
            if (assemblyCache.ContainsKey(dllFullPath))
            {
                return assemblyCache[dllFullPath];
            }
            Assembly assembly = null;
            assembly = Assembly.Load(dllFullPath.GetBinFileFullPath(".dll").LoadFileStream());
            assemblyCache.Add(dllFullPath, assembly);
            return assembly;
        }

        public static object LoadDynamicDLLClass(this string dllFileName, string className = "")
        {
            dllFileName = dllFileName.GetBinFileFullPath(".dll");
            className = (className.Length == 0) ? dllFileName.GetFileNameWithoutExtension() : className;
            if (classCache.ContainsKey(dllFileName + className))
            {
                return classCache[dllFileName + className];
            }
            object obj2 = Activator.CreateInstance(dllFileName.LoadDynamicDLLAssembly().GetType(className, false, true));
            classCache.Add(dllFileName + className, obj2);
            return obj2;
        }

        public static byte[] LoadFileStream(this string dllFullPath)
        {
            return new FileStream(dllFullPath.GetBinFileFullPath(".dll"), FileMode.Open).ToBytes();
        }

        public static string LowerFirstChar(this string str)
        {
            if (str.IsNullEmpty())
            {
                return string.Empty;
            }
            if (str.Length == 1)
            {
                return str.ToLower();
            }
            return (str.ToLower().Substring(0, 1) + str.Substring(1, str.Length - 1));
        }

        public static string LowerFirstChar2(this string str)
        {
            if (str.IsNullEmpty())
            {
                return string.Empty;
            }
            string str2 = str.Substring(0, 1).ToLower();
            if (str2 == str.Substring(0, 1))
            {
                return ("_" + str);
            }
            if (str.Length == 1)
            {
                return str.ToLower();
            }
            return (str2 + str.Substring(1, str.Length - 1));
        }

        public static string Native2Ascii(this string str)
        {
            string str2 = "";
            if (!string.IsNullOrEmpty(str))
            {
                for (int i = 1; i < str.Length; i++)
                {
                    str2 = str2 + @"\u" + ((int) str[i]).ToString("x");
                }
            }
            return str2.Trim();
        }

        public static string PadLeft(this string s, string pad)
        {
            return s.PadLeft(pad, (s.Length + pad.Length), false);
        }

        public static string PadLeft(this string s, string pad, int totalWidth, bool cutOff)
        {
            if (s.IsNullEmpty())
            {
                return string.Empty;
            }
            if (s.Length >= totalWidth)
            {
                return s;
            }
            int length = pad.Length;
            string str = s;
            while (str.Length < totalWidth)
            {
                str = str + pad;
            }
            if (cutOff)
            {
                str = str.Substring(0, totalWidth);
            }
            return str;
        }

        public static string PadRight(this string s, string pad)
        {
            return s.PadRight(pad, (s.Length + pad.Length), false);
        }

        public static string PadRight(this string s, string pad, int length, bool cutOff)
        {
            if (s.IsNullEmpty())
            {
                return string.Empty;
            }
            if (s.Length >= length)
            {
                return s;
            }
            string str = string.Empty;
            while (str.Length < (length - s.Length))
            {
                str = str + pad;
            }
            if (cutOff)
            {
                str = str.Substring(0, length - s.Length);
            }
            return (str + s);
        }

        public static string RemoveAllHTML(this string content)
        {
            if (content.IsNullEmpty())
            {
                return string.Empty;
            }
            string pattern = "<[^>]*>";
            return Regex.Replace(content, pattern, string.Empty, RegexOptions.IgnoreCase);
        }

        public static string RemoveEmptyNodes(string xml)
        {
            XmlDocument document = new XmlDocument();
            document.LoadXml(xml);
            foreach (XmlNode node in document.SelectNodes("//node()"))
            {
                if ((node.ChildNodes.Count == 0) && (node.InnerText == string.Empty))
                {
                    node.ParentNode.RemoveChild(node);
                }
            }
            StringWriter w = new StringWriter();
            XmlTextWriter writer2 = new XmlTextWriter(w) {
                Formatting = Formatting.Indented,
                Indentation = 2
            };
            document.PreserveWhitespace = true;
            document.WriteTo(writer2);
            xml = w.ToString();
            w.Close();
            writer2.Close();
            return xml;
        }

        public static string RemoveHTML(this string HtmlCode)
        {
            if (HtmlCode.IsNullEmpty())
            {
                return string.Empty;
            }
            string input = HtmlCode;
            input = new Regex("<br>", RegexOptions.IgnoreCase).Replace(input, "\n");
            foreach (Match match in Regex.Matches(HtmlCode, "<[^{><}]*>"))
            {
                input = input.Replace(match.Value, "");
            }
            return new Regex("\n", RegexOptions.IgnoreCase).Replace(input, "<br>");
        }

        public static string RemoveJsonNull(this string json)
        {
            json = Regex.Replace(json, ",\"\\w*\":null", string.Empty);
            json = Regex.Replace(json, "\"\\w*\":null,", string.Empty);
            json = Regex.Replace(json, "\"\\w*\":null", string.Empty);
            return json;
        }

        public static string RemovePrefix(this string s, string prefix)
        {
            if (s.IsNullEmpty())
            {
                return string.Empty;
            }
            return Regex.Replace(s, "^" + prefix, string.Empty, RegexOptions.IgnoreCase);
        }

        public static string RemoveSuffix(this string s, string suffix)
        {
            if (s.IsNullEmpty())
            {
                return string.Empty;
            }
            return Regex.Replace(s, suffix + "$", string.Empty, RegexOptions.IgnoreCase);
        }

        public static string Replace(this string RegValue, string regStart, string regEnd)
        {
            if (RegValue.IsNullEmpty())
            {
                return string.Empty;
            }
            string str = RegValue;
            if ((RegValue != "") && RegValue.IsNotNull())
            {
                if ((regStart != "") && regStart.IsNotNull())
                {
                    str = str.Replace(regStart, "");
                }
                if ((regEnd != "") && regEnd.IsNotNull())
                {
                    str = str.Replace(regEnd, "");
                }
            }
            return str;
        }

        public static string ReplaceRN(this string input, string replace = " ")
        {
            string pattern = @"[\r|\n]";
            Regex regex = new Regex(pattern, RegexOptions.Multiline | RegexOptions.IgnoreCase);
            return regex.Replace(input, replace);
        }

        public static string ReplaceRNToBR(this string input)
        {
            return input.Replace("\r\n", "<br />").Replace("\n", "<br />");
        }

        public static string ReplaceWith(this string value, string regexPattern, string replaceValue)
        {
            if (value.IsNullEmpty())
            {
                return string.Empty;
            }
            return value.ReplaceWith(regexPattern, replaceValue, RegexOptions.None);
        }

        public static string ReplaceWith(this string value, string regexPattern, MatchEvaluator evaluator)
        {
            return value.ReplaceWith(regexPattern, RegexOptions.None, evaluator);
        }

        public static string ReplaceWith(this string value, string regexPattern, string ReplaceString, bool IsCaseInsensetive)
        {
            if (value.IsNullEmpty())
            {
                return string.Empty;
            }
            return Regex.Replace(value, regexPattern, ReplaceString, IsCaseInsensetive ? RegexOptions.IgnoreCase : RegexOptions.None);
        }

        public static string ReplaceWith(this string value, string regexPattern, string replaceValue, RegexOptions options)
        {
            if (value.IsNullEmpty())
            {
                return string.Empty;
            }
            return Regex.Replace(value, regexPattern, replaceValue, options);
        }

        public static string ReplaceWith(this string value, string regexPattern, RegexOptions options, MatchEvaluator evaluator)
        {
            if (value.IsNullEmpty())
            {
                return string.Empty;
            }
            return Regex.Replace(value, regexPattern, evaluator, options);
        }

        public static string Reverse(this string value)
        {
            if (value.IsNullEmpty())
            {
                return string.Empty;
            }
            char[] array = value.ToCharArray();
            Array.Reverse(array);
            return new string(array);
        }

        public static string Right(this string str, int length)
        {
            if ((length <= 0) || (str.Length == 0))
            {
                return string.Empty;
            }
            if (str.Length <= length)
            {
                return str;
            }
            return str.Substring(str.Length - length, length);
        }

        public static string SafeSql(this string obj)
        {
            string str = obj.ToString();
            str = str.IsNullEmpty() ? "" : str.Replace("'", "''");
            str = new Regex("exec", RegexOptions.IgnoreCase).Replace(str, "&#101;xec");
            str = new Regex("xp_cmdshell", RegexOptions.IgnoreCase).Replace(str, "&#120;p_cmdshell");
            str = new Regex("select", RegexOptions.IgnoreCase).Replace(str, "&#115;elect");
            str = new Regex("insert", RegexOptions.IgnoreCase).Replace(str, "&#105;nsert");
            str = new Regex("update", RegexOptions.IgnoreCase).Replace(str, "&#117;pdate");
            str = new Regex("delete", RegexOptions.IgnoreCase).Replace(str, "&#100;elete");
            str = new Regex("drop", RegexOptions.IgnoreCase).Replace(str, "&#100;rop");
            str = new Regex("create", RegexOptions.IgnoreCase).Replace(str, "&#99;reate");
            str = new Regex("rename", RegexOptions.IgnoreCase).Replace(str, "&#114;ename");
            str = new Regex("truncate", RegexOptions.IgnoreCase).Replace(str, "&#116;runcate");
            str = new Regex("alter", RegexOptions.IgnoreCase).Replace(str, "&#97;lter");
            str = new Regex("exists", RegexOptions.IgnoreCase).Replace(str, "&#101;xists");
            str = new Regex("master.", RegexOptions.IgnoreCase).Replace(str, "&#109;aster.");
            return new Regex("restore", RegexOptions.IgnoreCase).Replace(str, "&#114;estore");
        }

        public static string SafeSqlSimple(this string obj)
        {
            string str = obj.ToString();
            return (str.IsNullEmpty() ? "" : str.Replace("'", "''"));
        }

        public static string ShowHtml(this string htmlStr)
        {
            if (htmlStr.IsNullEmpty())
            {
                return string.Empty;
            }
            string input = htmlStr;
            input = Regex.Replace(input, @"(script|frame|form|meta|behavior|style)([\s|:|>])+", "_$1.$2", RegexOptions.IgnoreCase);
            input = new Regex("<script", RegexOptions.IgnoreCase).Replace(input, "<_script");
            input = new Regex("<object", RegexOptions.IgnoreCase).Replace(input, "<_object");
            input = new Regex("javascript:", RegexOptions.IgnoreCase).Replace(input, "_javascript:");
            input = new Regex("vbscript:", RegexOptions.IgnoreCase).Replace(input, "_vbscript:");
            input = new Regex("expression", RegexOptions.IgnoreCase).Replace(input, "_expression");
            input = new Regex("@import", RegexOptions.IgnoreCase).Replace(input, "_@import");
            input = new Regex("<iframe", RegexOptions.IgnoreCase).Replace(input, "<_iframe");
            input = Regex.Replace(new Regex("<frameset", RegexOptions.IgnoreCase).Replace(input, "<_frameset"), @"(\<|\s+)o([a-z]+\s?=)", "$1_o$2", RegexOptions.IgnoreCase);
            return new Regex(" (on[a-zA-Z ]+)=", RegexOptions.IgnoreCase).Replace(input, " _$1=");
        }

        public static string ShowXmlHtml(this string htmlStr)
        {
            if (htmlStr.IsNullEmpty())
            {
                return string.Empty;
            }
            return htmlStr.Replace("&", "&amp;").Replace(">", "&gt;").Replace("<", "&lt;");
        }

        public static string[] Split(this string value, string regexPattern)
        {
            return value.Split(regexPattern, RegexOptions.None);
        }

        public static string[] Split(this string value, string regexPattern, RegexOptions options)
        {
            if (value.IsNullEmpty())
            {
                return new string[0];
            }
            return Regex.Split(value, regexPattern, options);
        }

        public static string SubHtmlString(this string htmlString, int maxLength, string flg)
        {
            bool flag = true;
            StringBuilder builder = new StringBuilder();
            int num = 0;
            char ch = ' ';
            int length = -1;
            Dictionary<int, string> dictionary = new Dictionary<int, string>();
            string str = "";
            int num3 = 0;
            int num4 = 0;
            int num5 = 0;
            for (num5 = 0; num5 < htmlString.Length; num5++)
            {
                ch = htmlString[num5];
                if (ch == '<')
                {
                    flag = false;
                }
                if (flag)
                {
                    num4++;
                }
                if (ch == '>')
                {
                    flag = true;
                }
            }
            num5 = 0;
            while (num5 < htmlString.Length)
            {
                ch = htmlString[num5];
                builder.Append(ch);
                if (ch == '<')
                {
                    flag = false;
                }
                if (flag)
                {
                    if (ch == ' ')
                    {
                        length = num5;
                    }
                    num++;
                }
                else
                {
                    str = str + ch;
                }
                if (ch == '>')
                {
                    flag = true;
                    if (((str.IndexOf("<") != -1) && (str.IndexOf("/>") == -1)) && (str.IndexOf("</") == -1))
                    {
                        if (str.IndexOf(" ") != -1)
                        {
                            str = str.Substring(1, str.IndexOf(" ") - 1);
                        }
                        else
                        {
                            str = str.Substring(1, str.Length - 2);
                        }
                        dictionary[num3] = str;
                        num3++;
                    }
                    else if (str.IndexOf("</") != -1)
                    {
                        dictionary[num3 - 1] = null;
                        num3--;
                    }
                    str = "";
                }
                if (num == maxLength)
                {
                    break;
                }
                num5++;
            }
            if (maxLength < num4)
            {
                if (length != -1)
                {
                    builder = new StringBuilder(htmlString.Substring(0, length));
                }
                else
                {
                    builder = new StringBuilder(htmlString.Substring(0, num5));
                }
            }
            for (int i = dictionary.Count - 1; i >= 0; i--)
            {
                if (dictionary[i].IsNotNull())
                {
                    builder.Append("</" + dictionary[i] + ">");
                }
            }
            if (maxLength < num4)
            {
                builder.Append(flg);
            }
            return builder.ToString();
        }

        public static string SubString(this string strInput, int len, string flg)
        {
            if (strInput.IsNullEmpty())
            {
                return string.Empty;
            }
            string str = string.Empty;
            if (len < 0)
            {
                return str;
            }
            byte[] bytes = Encoding.Default.GetBytes(strInput);
            if (bytes.Length > len)
            {
                int length = len;
                int[] numArray = new int[len];
                byte[] destinationArray = null;
                int num2 = 0;
                for (int i = 0; i < len; i++)
                {
                    if (bytes[i] > 0x7f)
                    {
                        num2++;
                        if (num2 == 3)
                        {
                            num2 = 1;
                        }
                    }
                    else
                    {
                        num2 = 0;
                    }
                    numArray[i] = num2;
                }
                if ((bytes[len - 1] > 0x7f) && (numArray[len - 1] == 1))
                {
                    length = len + 1;
                }
                destinationArray = new byte[length];
                Array.Copy(bytes, destinationArray, length);
                return (Encoding.Default.GetString(destinationArray) + ((len >= strInput.CnLength()) ? "" : flg));
            }
            return strInput;
        }

        public static byte[] To16Bytes(this string s)
        {
            s = s.Replace(" ", "");
            byte[] buffer = new byte[s.Length / 2];
            for (int i = 0; i < s.Length; i += 2)
            {
                buffer[i / 2] = Convert.ToByte(s.Substring(i, 2), 0x10);
            }
            return buffer;
        }

        public static long ToBigInt(this string strValue)
        {
            return strValue.ToBigInt(0L);
        }

        public static long ToBigInt(this string strValue, long defValue)
        {
            long result = 0L;
            long.TryParse(strValue, out result);
            if (result != 0L)
            {
                return result;
            }
            return defValue;
        }

        public static bool ToBool(this string strValue)
        {
            return strValue.ToBool(false);
        }

        public static bool ToBool(this string strValue, bool defValue)
        {
            if (!strValue.IsNullEmpty())
            {
                if (string.Compare(strValue, "true", true) == 0)
                {
                    return true;
                }
                if (string.Compare(strValue, "false", true) == 0)
                {
                    return false;
                }
                if (string.Compare(strValue, "1", true) == 0)
                {
                    return true;
                }
                if (string.Compare(strValue, "0", true) == 0)
                {
                    return false;
                }
            }
            return defValue;
        }

        public static byte[] ToBytes(this string value)
        {
            return value.ToBytes(null);
        }

        public static byte[] ToBytes(this string value, Encoding encoding)
        {
            if (value.IsNullEmpty())
            {
                return null;
            }
            encoding = encoding ?? Encoding.Default;
            return encoding.GetBytes(value);
        }

        public static Color ToColor(this string s)
        {
            if (s.IsNullEmpty())
            {
                return new Color();
            }
            s = s.Replace("#", string.Empty);
            byte alpha = Convert.ToByte("ff", 0x10);
            byte startIndex = 0;
            if (s.Length == 8)
            {
                alpha = Convert.ToByte(s.Substring(startIndex, 2), 0x10);
                startIndex = 2;
            }
            byte red = Convert.ToByte(s.Substring(startIndex, 2), 0x10);
            startIndex = (byte) (startIndex + 2);
            byte green = Convert.ToByte(s.Substring(startIndex, 2), 0x10);
            startIndex = (byte) (startIndex + 2);
            byte blue = Convert.ToByte(s.Substring(startIndex, 2), 0x10);
            return Color.FromArgb(alpha, red, green, blue);
        }

        public static DateTime ToDateTime(this string DateTimeStr)
        {
            if (DateTimeStr.IsNullEmpty())
            {
                return DateTime.Now;
            }
            return DateTime.Parse(DateTimeStr);
        }

        public static DateTime ToDateTime(this string DateTimeStr, DateTime defDate)
        {
            DateTime.TryParse(DateTimeStr, out defDate);
            return defDate;
        }

        public static DateTime? ToDateTime(this string DateTimeStr, DateTime? defDate)
        {
            DateTime now = DateTime.Now;
            DateTime time2 = now;
            DateTime.TryParse(DateTimeStr, out now);
            if (now == time2)
            {
                return defDate;
            }
            return new DateTime?(now);
        }

        public static string ToDateTime(this string fDateTime, string formatStr)
        {
            return fDateTime.ToDateTime().ToString(formatStr);
        }

        public static string ToDBC(this string input)
        {
            char[] chArray = input.ToCharArray();
            for (int i = 0; i < chArray.Length; i++)
            {
                if (chArray[i] == '　')
                {
                    chArray[i] = ' ';
                }
                else if ((chArray[i] > 0xff00) && (chArray[i] < 0xff5f))
                {
                    chArray[i] = (char) (chArray[i] - 0xfee0);
                }
            }
            return new string(chArray);
        }

        public static DbType ToDbTypeForMySql(this string mySqlType)
        {
            switch (mySqlType.ToLowerInvariant())
            {
                case "longtext":
                case "nchar":
                case "ntext":
                case "text":
                case "sysname":
                case "varchar":
                case "nvarchar":
                    return DbType.String;

                case "bit":
                case "tinyint":
                    return DbType.Boolean;

                case "decimal":
                case "float":
                case "newdecimal":
                case "numeric":
                case "double":
                case "real":
                    return DbType.Decimal;

                case "bigint":
                    return DbType.Int64;

                case "int":
                case "int32":
                case "integer":
                    return DbType.Int32;

                case "int16":
                case "smallint":
                    return DbType.Int16;

                case "date":
                case "time":
                case "datetime":
                case "smalldatetime":
                    return DbType.DateTime;

                case "image":
                case "varbinary":
                case "binary":
                case "blob":
                case "longblob":
                    return DbType.Binary;

                case "char":
                    return DbType.AnsiStringFixedLength;

                case "currency":
                case "money":
                case "smallmoney":
                    return DbType.Currency;

                case "timestamp":
                    return DbType.DateTime;

                case "uniqueidentifier":
                    return DbType.Binary;

                case "uint16":
                    return DbType.UInt16;

                case "uint32":
                    return DbType.UInt32;
            }
            return DbType.String;
        }

        public static DbType ToDbTypeForSql2005(this string sqlType)
        {
            switch (sqlType)
            {
                case "varchar":
                    return DbType.AnsiString;

                case "nvarchar":
                    return DbType.String;

                case "int":
                    return DbType.Int32;

                case "uniqueidentifier":
                    return DbType.Guid;

                case "datetime":
                case "datetime2":
                    return DbType.DateTime;

                case "bigint":
                    return DbType.Int64;

                case "binary":
                    return DbType.Binary;

                case "bit":
                    return DbType.Boolean;

                case "char":
                    return DbType.AnsiStringFixedLength;

                case "decimal":
                    return DbType.Decimal;

                case "float":
                    return DbType.Double;

                case "image":
                    return DbType.Binary;

                case "money":
                    return DbType.Currency;

                case "nchar":
                    return DbType.String;

                case "ntext":
                    return DbType.String;

                case "numeric":
                    return DbType.Decimal;

                case "real":
                    return DbType.Single;

                case "smalldatetime":
                    return DbType.DateTime;

                case "smallint":
                    return DbType.Int16;

                case "smallmoney":
                    return DbType.Currency;

                case "sql_variant":
                    return DbType.String;

                case "sysname":
                    return DbType.String;

                case "text":
                    return DbType.AnsiString;

                case "timestamp":
                    return DbType.Binary;

                case "tinyint":
                    return DbType.Byte;

                case "varbinary":
                    return DbType.Binary;
            }
            return DbType.AnsiString;
        }

        public static DbType ToDbTypeForSQLite(this string sqlType)
        {
            switch (sqlType.ToLowerInvariant())
            {
                case "longtext":
                case "nchar":
                case "ntext":
                case "text":
                case "sysname":
                case "varchar":
                case "nvarchar":
                    return DbType.String;

                case "bit":
                case "tinyint":
                    return DbType.Boolean;

                case "decimal":
                case "float":
                case "newdecimal":
                case "numeric":
                case "double":
                case "real":
                    return DbType.Decimal;

                case "int":
                case "int32":
                    return DbType.Int32;

                case "integer":
                    return DbType.Int64;

                case "int16":
                case "smallint":
                    return DbType.Int16;

                case "date":
                case "time":
                case "datetime":
                case "smalldatetime":
                    return DbType.DateTime;

                case "image":
                case "varbinary":
                case "binary":
                case "blob":
                case "longblob":
                    return DbType.Binary;

                case "char":
                    return DbType.AnsiStringFixedLength;

                case "currency":
                case "money":
                case "smallmoney":
                    return DbType.Currency;

                case "timestamp":
                    return DbType.DateTime;

                case "uniqueidentifier":
                    return DbType.Guid;

                case "uint16":
                    return DbType.UInt16;

                case "uint32":
                    return DbType.UInt32;
            }
            return DbType.String;
        }

        public static decimal ToDecimal(this string strValue)
        {
            return strValue.ToDecimal(0M);
        }

        public static decimal ToDecimal(this string strValue, decimal defValue)
        {
            decimal result = 0M;
            decimal.TryParse(strValue, out result);
            if (!(result == 0M))
            {
                return result;
            }
            return defValue;
        }

        public static T ToEnum<T>(this string value)
        {
            return value.ToEnum<T>(false);
        }

        public static T ToEnum<T>(this string value, bool ignorecase)
        {
            if (value.IsNull())
            {
                throw new ArgumentNullException("value不能为空");
            }
            value = value.Trim();
            if (value.Length == 0)
            {
                throw new ArgumentNullException("value不是有效Enum字符串", "value");
            }
            Type enumType = typeof(T);
            if (!enumType.IsEnum)
            {
                throw new ArgumentException("Type不是有效Enum", "T");
            }
            return (T) Enum.Parse(enumType, value, ignorecase);
        }

        public static T ToEnum<T>(string value, T defaultValue) where T: struct, IConvertible
        {
            if (!typeof(T).IsEnum)
            {
                throw new ArgumentException("T必须是Enum类型");
            }
            if (!string.IsNullOrEmpty(value))
            {
                foreach (T local in Enum.GetValues(typeof(T)))
                {
                    if (local.ToString().ToLower().Equals(value.Trim().ToLower()))
                    {
                        return local;
                    }
                }
            }
            return defaultValue;
        }

        public static void ToFile(this string str, string fileName)
        {
            str.ToFile(fileName, Encoding.UTF8, true);
        }

        public static void ToFile(this string str, string fileName, Encoding encoding)
        {
            str.ToFile(fileName, encoding, true);
        }

        public static void ToFile(this string str, string fileName, Encoding encoding, bool isOver = true)
        {
            if (isOver)
            {
                FileDirectory.FileDelete(fileName);
            }
            Pub.Class.Log.Write(fileName, str, encoding);
        }

        public static float ToFloat(this string strValue)
        {
            return strValue.ToFloat(0f);
        }

        public static float ToFloat(this string strValue, float defValue)
        {
            float result = 0f;
            float.TryParse(strValue, out result);
            if (result != 0f)
            {
                return result;
            }
            return defValue;
        }

        public static Guid ToGuid(this string target)
        {
            if (target.IsGuid())
            {
                return new Guid(target);
            }
            return Guid.Empty;
        }

        public static int ToInt(this string strValue)
        {
            return strValue.ToInt(0);
        }

        public static int ToInt(this string strValue, int defValue)
        {
            int result = 0;
            int.TryParse(strValue, out result);
            if (result != 0)
            {
                return result;
            }
            return defValue;
        }

        public static int ToInteger(this string strValue)
        {
            return strValue.ToInteger(0);
        }

        public static int ToInteger(this string strValue, int defValue)
        {
            int result = 0;
            int.TryParse(strValue, out result);
            if (result != 0)
            {
                return result;
            }
            return defValue;
        }

        public static decimal ToMoney(this string strValue)
        {
            return strValue.ToMoney(0M);
        }

        public static decimal ToMoney(this string strValue, decimal defValue)
        {
            decimal result = 0M;
            decimal.TryParse(strValue, out result);
            if (!(result == 0M))
            {
                return result;
            }
            return defValue;
        }

        public static T? ToNullable<T>(this string s) where T: struct
        {
            T? nullable = null;
            if (!s.Trim().IsNullEmpty())
            {
                nullable = (T?) TypeDescriptor.GetConverter(typeof(T?)).ConvertFrom(s);
            }
            return nullable;
        }

        public static T? ToNullable<T>(this T value) where T: struct
        {
            if (!value.IsDefault<T>())
            {
                return new T?(value);
            }
            return null;
        }

        public static string ToOriginal(this string text)
        {
            StringBuilder builder = new StringBuilder();
            foreach (char ch in text.ToCharArray())
            {
                switch (ch)
                {
                    case '\'':
                    {
                        builder.Append(@"\'");
                        continue;
                    }
                    case '\\':
                    {
                        builder.Append(@"\\");
                        continue;
                    }
                    case '\a':
                    {
                        builder.Append(@"\a");
                        continue;
                    }
                    case '\b':
                    {
                        builder.Append(@"\b");
                        continue;
                    }
                    case '\t':
                    {
                        builder.Append(@"\t");
                        continue;
                    }
                    case '\n':
                    {
                        builder.Append(@"\n");
                        continue;
                    }
                    case '\v':
                    {
                        builder.Append(@"\b");
                        continue;
                    }
                    case '\r':
                    {
                        builder.Append(@"\r");
                        continue;
                    }
                    case '"':
                    {
                        builder.Append("\\\"");
                        continue;
                    }
                }
                if ((ch < ' ') || (ch == '\x007f'))
                {
                    builder.Append(@"\u" + ((ushort) ch).ToString("x4"));
                }
                else
                {
                    builder.Append(ch);
                }
            }
            return builder.ToString();
        }

        public static string ToPinyin(this string s)
        {
            if (s.IsNullEmpty())
            {
                return string.Empty;
            }
            return PinYin.Instance().Search(s).ToLower();
        }

        public static string ToPinyinChar(this string s)
        {
            if (s.IsNullEmpty())
            {
                return string.Empty;
            }
            string str = PinYin.Instance().SearchCap(s);
            if (str.ToLower() == str.ToUpper())
            {
                return "*";
            }
            return str.ToLower();
        }

        public static string ToPinyinChar2(this string c)
        {
            byte[] bytes = new byte[2];
            bytes = Encoding.Default.GetBytes(c);
            int num = (bytes[0] * 0x100) + bytes[1];
            if (num >= 0xb0a1)
            {
                if (num < 0xb0c5)
                {
                    return "a";
                }
                if (num < 0xb2c1)
                {
                    return "b";
                }
                if (num < 0xb4ee)
                {
                    return "c";
                }
                if (num < 0xb6ea)
                {
                    return "d";
                }
                if (num < 0xb7a2)
                {
                    return "e";
                }
                if (num < 0xb8c1)
                {
                    return "f";
                }
                if (num < 0xb9fe)
                {
                    return "g";
                }
                if (num < 0xbbf7)
                {
                    return "h";
                }
                if (num < 0xbfa6)
                {
                    return "g";
                }
                if (num < 0xc0ac)
                {
                    return "k";
                }
                if (num < 0xc2e8)
                {
                    return "l";
                }
                if (num < 0xc4c3)
                {
                    return "m";
                }
                if (num < 0xc5b6)
                {
                    return "n";
                }
                if (num < 0xc5be)
                {
                    return "o";
                }
                if (num < 0xc6da)
                {
                    return "p";
                }
                if (num < 0xc8bb)
                {
                    return "q";
                }
                if (num < 0xc8f6)
                {
                    return "r";
                }
                if (num < 0xcbfa)
                {
                    return "s";
                }
                if (num < 0xcdda)
                {
                    return "t";
                }
                if (num < 0xcef4)
                {
                    return "w";
                }
                if (num < 0xd1b9)
                {
                    return "x";
                }
                if (num < 0xd4d1)
                {
                    return "y";
                }
                if (num < 0xd7fa)
                {
                    return "z";
                }
            }
            return "*";
        }

        public static string ToSBC(this string input)
        {
            char[] chArray = input.ToCharArray();
            for (int i = 0; i < chArray.Length; i++)
            {
                if (chArray[i] == ' ')
                {
                    chArray[i] = '　';
                }
                else if (chArray[i] < '\x007f')
                {
                    chArray[i] = (char) (chArray[i] + 0xfee0);
                }
            }
            return new string(chArray);
        }

        public static string ToSChinese(this string str)
        {
            if (str.IsNullEmpty())
            {
                return string.Empty;
            }
            return Microsoft.VisualBasic.Strings.StrConv(str, VbStrConv.SimplifiedChinese, 0);
        }

        public static SecureString ToSecureString(this string str)
        {
            SecureString str2 = new SecureString();
            foreach (char ch in str)
            {
                str2.AppendChar(ch);
            }
            return str2;
        }

        public static short ToSmallInt(this string strValue)
        {
            return strValue.ToSmallInt(0);
        }

        public static short ToSmallInt(this string strValue, short defValue)
        {
            short result = 0;
            short.TryParse(strValue, out result);
            if (result != 0)
            {
                return result;
            }
            return defValue;
        }

        public static string ToTChinese(this string str)
        {
            if (str.IsNullEmpty())
            {
                return string.Empty;
            }
            return Microsoft.VisualBasic.Strings.StrConv(str, VbStrConv.TraditionalChinese, 0);
        }

        public static byte ToTinyInt(this string strValue)
        {
            return strValue.ToTinyInt(0);
        }

        public static byte ToTinyInt(this string strValue, byte defValue)
        {
            byte result = 0;
            byte.TryParse(strValue, out result);
            if (result != 0)
            {
                return result;
            }
            return defValue;
        }

        public static Guid ToUniqueIdentifier(this string target)
        {
            return target.ToGuid();
        }

        public static byte[] ToUTF8Bytes(this string valueToExpand)
        {
            UTF8Encoding encoding = new UTF8Encoding();
            return encoding.GetBytes(valueToExpand);
        }

        public static XDocument ToXDocument(this string xml)
        {
            return XDocument.Parse(xml);
        }

        public static XmlDocument ToXmlDOM(this string xml)
        {
            XmlDocument document = new XmlDocument();
            document.LoadXml(xml);
            return document;
        }

        public static XPathNavigator ToXPath(this string xml)
        {
            XPathDocument document = new XPathDocument(new StringReader(xml));
            return document.CreateNavigator();
        }

        public static string Trim(this string str, int len)
        {
            str = str.TrimStart(len);
            str = str.TrimEnd(len);
            return str;
        }

        public static string Trim(this string str, string nchar)
        {
            str = str.TrimStart(nchar);
            str = str.TrimEnd(nchar);
            return str;
        }

        public static string TrimEnd(this string str)
        {
            if (!str.IsNullEmpty())
            {
                return str.Remove(str.Length - 1, 1);
            }
            return string.Empty;
        }

        public static string TrimEnd(this string str, int len)
        {
            if (str.IsNullEmpty())
            {
                return string.Empty;
            }
            if (str.Length >= len)
            {
                return str.Remove(str.Length - len, len);
            }
            return str;
        }

        public static string TrimEnd(this string str, string lastchar)
        {
            if (str.EndsWith(lastchar, true, null))
            {
                return str.Substring(0, str.Length - lastchar.Length);
            }
            return str;
        }

        public static string TrimIndexEnd(this string obj, string end)
        {
            int length = obj.LastIndexOf(end);
            if (length == -1)
            {
                return obj;
            }
            return obj.Substring(0, length);
        }

        public static string TrimIndexStart(this string obj, string start)
        {
            int index = obj.IndexOf(start);
            if (index == -1)
            {
                return obj;
            }
            if (obj.Length == start.Length)
            {
                return string.Empty;
            }
            return obj.Substring(index + start.Length);
        }

        public static string TrimStart(this string str)
        {
            if (!str.IsNullEmpty())
            {
                return str.Remove(0, 1);
            }
            return string.Empty;
        }

        public static string TrimStart(this string str, int len)
        {
            if (str.IsNullEmpty())
            {
                return string.Empty;
            }
            if (str.Length >= len)
            {
                return str.Remove(0, len);
            }
            return str;
        }

        public static string TrimStart(this string str, string prevchar)
        {
            if (str.StartsWith(prevchar, true, null))
            {
                return str.Substring(prevchar.Length);
            }
            return str;
        }

        public static bool True(this string source)
        {
            if (string.Compare(source, "true", true) != 0)
            {
                return (string.Compare(source, "1", true) == 0);
            }
            return true;
        }

        public static string UBB(this string chr)
        {
            if (chr.IsNullEmpty())
            {
                return string.Empty;
            }
            chr = chr.HtmlEncode();
            chr = Regex.Replace(chr, @"<script(?<x>[^\>]*)>(?<y>[^\>]*)            \</script\>", "&lt;script$1&gt;$2&lt;/script&gt;", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[url=(?<x>[^\]]*)\](?<y>[^\]]*)\[/url\]", "<a href=$1  target=_blank>$2</a>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[url\](?<x>[^\]]*)\[/url\]", "<a href=$1 target=_blank>$1</a>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[email=(?<x>[^\]]*)\](?<y>[^\]]*)\[/email\]", "<a href=$1>$2</a>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[email\](?<x>[^\]]*)\[/email\]", "<a href=$1>$1</a>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[flash](?<x>[^\]]*)\[/flash]", "<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 width=500 height=400><PARAM NAME=movie VALUE=\"$1\"><PARAM NAME=quality VALUE=high><embed src=\"$1\" quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width=500 height=400>$1</embed></OBJECT>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[img](?<x>[^\]]*)\[/img]", "<IMG SRC=\"$1\" border=0>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[color=(?<x>[^\]]*)\](?<y>[^\]]*)\[/color\]", "<font color=$1>$2</font>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[face=(?<x>[^\]]*)\](?<y>[^\]]*)\[/face\]", "<font face=$1>$2</font>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[size=1\](?<x>[^\]]*)\[/size\]", "<font size=1>$1</font>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[size=2\](?<x>[^\]]*)\[/size\]", "<font size=2>$1</font>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[size=3\](?<x>[^\]]*)\[/size\]", "<font size=3>$1</font>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[size=4\](?<x>[^\]]*)\[/size\]", "<font size=4>$1</font>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[align=(?<x>[^\]]*)\](?<y>[^\]]*)\[/align\]", "<align=$1>$2</align>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[fly](?<x>[^\]]*)\[/fly]", "<marquee width=90% behavior=alternate scrollamount=3>$1</marquee>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[move](?<x>[^\]]*)\[/move]", "<marquee scrollamount=3>$1</marquee>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[glow=(?<x>[^\]]*),(?<y>[^\]]*),(?<z>[^\]]*)\](?<w>[^\]]*)\[/glow\]", "<table width=$1 style='filter:glow(color=$2, strength=$3)'>$4</table>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[shadow=(?<x>[^\]]*),(?<y>[^\]]*),(?<z>[^\]]*)\](?<w>[^\]]*)\[/shadow\]", "<table width=$1 style='filter:shadow(color=$2, strength=$3)'>$4</table>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[b\](?<x>[^\]]*)\[/b\]", "<b>$1</b>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[i\](?<x>[^\]]*)\[/i\]", "<i>$1</i>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[u\](?<x>[^\]]*)\[/u\]", "<u>$1</u>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[code\](?<x>[^\]]*)\[/code\]", "<pre id=code><font size=1 face='Verdana, Arial' id=code>$1</font id=code></pre id=code>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[list\](?<x>[^\]]*)\[/list\]", "<ul>$1</ul>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[list=1\](?<x>[^\]]*)\[/list\]", "<ol type=1>$1</ol id=1>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[list=a\](?<x>[^\]]*)\[/list\]", "<ol type=a>$1</ol id=a>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[\*\](?<x>[^\]]*)\[/\*\]", "<li>$1</li>", RegexOptions.IgnoreCase);
            chr = Regex.Replace(chr, @"\[quote](?<x>.*)\[/quote]", "<center>—— 以下是引用 ——<table border='1' width='80%' cellpadding='10' cellspacing='0' ><tr><td>$1</td></tr></table></center>", RegexOptions.IgnoreCase);
            return chr;
        }

        public static string UnHtml(this string htmlStr)
        {
            if (htmlStr.IsNullEmpty())
            {
                return string.Empty;
            }
            return htmlStr.Replace("\"", "\\\"").ShowXmlHtml().Replace(" ", "&nbsp;").Replace("\n", "<br />");
        }

        public static string UnHtmlNoBR(this string htmlStr)
        {
            if (htmlStr.IsNullEmpty())
            {
                return string.Empty;
            }
            return htmlStr.Replace("\"", "\\\"").ShowXmlHtml().Replace(" ", "&nbsp;");
        }

        public static string UpperFirstChar(this string str)
        {
            if (str.IsNullEmpty())
            {
                return string.Empty;
            }
            if (str.Length == 1)
            {
                return str.ToUpper();
            }
            return (str.ToUpper().Substring(0, 1) + str.Substring(1, str.Length - 1));
        }

        public static string UpperFirstChar2(this string str)
        {
            if (str.IsNullEmpty())
            {
                return string.Empty;
            }
            string str2 = str.Substring(0, 1).ToUpper();
            if (str2 == str.Substring(0, 1))
            {
                return ("_" + str);
            }
            if (str.Length == 1)
            {
                return str.ToUpper();
            }
            return (str2 + str.Substring(1, str.Length - 1));
        }

        public static string UrlDecode(this string str)
        {
            if (str.IsNullEmpty())
            {
                return string.Empty;
            }
            return HttpUtility.UrlDecode(str);
        }

        public static string UrlDecode(this string str, Encoding encoding)
        {
            if (str.IsNullEmpty())
            {
                return string.Empty;
            }
            return HttpUtility.UrlDecode(str, encoding);
        }

        public static string UrlEncode(this string str)
        {
            if (str.IsNullEmpty())
            {
                return string.Empty;
            }
            return HttpUtility.UrlEncode(str);
        }

        public static string UrlEncode(this string str, Encoding encoding)
        {
            if (str.IsNullEmpty())
            {
                return string.Empty;
            }
            return HttpUtility.UrlEncode(str, encoding);
        }

        public static string UrlEncode2(this string value)
        {
            StringBuilder builder = new StringBuilder();
            string str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~";
            foreach (char ch in value)
            {
                if (str.IndexOf(ch) != -1)
                {
                    builder.Append(ch);
                }
                else
                {
                    builder.Append('%' + string.Format("{0:X2}", (int) ch));
                }
            }
            return builder.ToString();
        }

        public static string UrlEncodeUnicode(this string str)
        {
            return HttpUtility.UrlEncodeUnicode(str);
        }

        public static string UrlPathEncode(this string str)
        {
            return HttpUtility.UrlPathEncode(str);
        }

        public static string UrlUpperEncode(this string str)
        {
            str = str.UrlEncode();
            if (str.IsNullEmpty())
            {
                return str;
            }
            string[] strArray = str.Split("%");
            StringBuilder builder = new StringBuilder();
            foreach (string str2 in strArray)
            {
                if (!str2.IsNullEmpty() && (str2.Length >= 2))
                {
                    builder.Append("%").Append(str2.Left(2).ToUpper());
                    if (str2.Length > 2)
                    {
                        builder.Append(str2.Right(str2.Length - 2));
                    }
                }
            }
            return builder.ToString();
        }

        public static string UTF8ToGB2312(this string str)
        {
            Encoding srcEncoding = Encoding.GetEncoding(0xfde9);
            Encoding encoding = Encoding.GetEncoding("gb2312");
            byte[] bytes = srcEncoding.GetBytes(str);
            byte[] buffer2 = Encoding.Convert(srcEncoding, encoding, bytes);
            return encoding.GetString(buffer2);
        }

        public static void Write(this string text)
        {
            Msg.Write(text);
        }

        public static void WriteEnd(this string text)
        {
            Msg.WriteEnd(text);
        }

        public static void WriteJSONEnd(this string json)
        {
            Msg.WriteJSONEnd(json);
        }

        public static void WriteJSONPEnd(this string json)
        {
            Msg.WriteJSONPEnd(json);
        }

        public static void WriteXMLEnd(this string xmlnode)
        {
            Msg.WriteXMLEnd(xmlnode);
        }

    }
}

